package com.cyl.sms.controller;

import com.cyl.manager.ums.domain.entity.Member;
import com.cyl.sms.service.SmsService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.domain.model.SmsResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;

import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;



@RestController
@RequestMapping("/sms")
public class SmsController {

    @Autowired
    private SmsService smsService;

    /**
     * 	发短信验证码
     */
    @GetMapping("/sendAliyun/logInPhone")
    public ResponseEntity<SmsResult> sendAliyun(){
        return smsService.sendAliyun(getPhone());
    }

    
    
    /**
     * 	获取当前登录的电话号码
     */
    @GetMapping("/getLogInPhone")
    public ResponseEntity<String> getLogInPhone(){
        return ResponseEntity.ok(getPhone());
    }
    
  

    private String getPhone() {
    	String phones = SecurityUtils.getLoginUser().getUser().getPhonenumber();
    	if(phones==null) {
            throw new RuntimeException("当前登录人员，手机号未设置！");
    	}
		return phones;
    }
}
